import App from './App'
import plugins from './plugins'
import store from './store'
import { toast } from '@/utils/common'

import { imgUrl, moneyStr, previewImg, callPhone, copyText, gotoPage } from '@/utils/ty'
import uviewPlus from '@/uni_modules/uview-plus'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
// 全局方法挂载
Vue.prototype.$store = store
Vue.prototype.toast = toast
Vue.prototype.imgUrl = imgUrl
Vue.prototype.moneyStr = moneyStr
Vue.prototype.previewImg = previewImg
Vue.prototype.callPhone = callPhone
Vue.prototype.copyText = copyText
Vue.prototype.gotoPage = gotoPage
App.mpType = 'app'
const app = new Vue({
	uviewPlus,
	store,
	plugins,
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
	app.use(uviewPlus, () => {
		return {
			options: {
				// 修改config对象的属性
				config: {
					// 只加载一次字体图标
					loadFontOnce: true
				}
			}
		}
	})
	app.use(store)
	app.use(plugins)
	// 全局方法挂载
	app.config.globalProperties.$store = store
	app.config.globalProperties.toast = toast
  app.config.globalProperties.imgUrl = imgUrl
  app.config.globalProperties.moneyStr = moneyStr
  app.config.globalProperties.previewImg = previewImg
  app.config.globalProperties.callPhone = callPhone
  app.config.globalProperties.copyText = copyText
  app.config.globalProperties.gotoPage = gotoPage
  return {
    app
  }
}
// #endif